import requests

url = 'https://api.live.bilibili.com/msg/send'

data = {
    'bubble':' 0',
    'msg':' 厉害',
    'color':' 16777215',
    'mode':' 1',
    'fontsize':' 25',
    'rnd':' 1666083549',
    'roomid':' 24492935',
    'csrf':' e1fec54deb29c357342c383f2b672928',
    'csrf_token':' e1fec54deb29c357342c383f2b672928',
}


headers = {
    'cookie': 'buvid3=93F751F9-0E7A-A623-6828-6172DBDBD50283674infoc; i-wanna-go-back=-1; _uuid=2EFE1A3A-F1067-BA71-254B-41410D6101642986018infoc; rpdid=|(u))|k))JRR0J\'uYR|Y|)lRu; buvid4=F6E3E002-8FAB-32E5-1938-23BA3EE717CC89567-022020422-HNYvTHSPdBQ9mVjLjG0fuIBW1wzXH8ujaYtt+RGS8N8VE2Qx/wrnwA%3D%3D; LIVE_BUVID=AUTO9316478725465049; is-2022-channel=1; CURRENT_BLACKGAP=0; blackside_state=0; nostalgia_conf=-1; fingerprint=06589226b191c7797728d27acb3dc290; buvid_fp_plain=undefined; SESSDATA=1ee9340c%2C1671797582%2C16c86%2A61; bili_jct=e1fec54deb29c357342c383f2b672928; DedeUserID=1758663895; DedeUserID__ckMd5=76b5d895881d79a6; sid=jkwahpgk; buvid_fp=06589226b191c7797728d27acb3dc290; b_ut=5; b_nut=100; bp_video_offset_1758663895=706765013631631400; CURRENT_QUALITY=80; CURRENT_FNVAL=4048; b_lsid=F6789DAF_183EA4B6975; _dfcaptcha=7bfeb950b18c93c2a984ecabaa6ac9f8; Hm_lvt_8a6e55dbd2870f0f5bc9194cddf32a02=1665242680,1665322732,1666083333; Hm_lpvt_8a6e55dbd2870f0f5bc9194cddf32a02=1666083333; PVID=7',
    'origin': 'https://live.bilibili.com',
    'referer': 'https://live.bilibili.com/24492935?hotRank=0&session_id=27bb57e43cdb7e5d5f34cbc2891b8092_199D6D66-AFC6-4D70-AFBB-D63F30E66C93&visit_id=2h0f8ny8pu00',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.42',
}
resp = requests.post(url=url, data=data, headers=headers)
print(resp.status_code)
print(resp.json())